home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
54200
/
54200.xpi
/
chrome
/
dogood.jar
/
content
/
DoGoodCookie.js
< prev
next >
Wrap
Text File
|
2010-01-05
|
2KB
|
60 lines
/**
* Functions for get\set cookie
*/
const DoGoodCookie =
{
/**
* Function for check ignoring sites.
*
* @param {object} doc - current loaded document
* @param {string} link - link of site
*/
isIgnore : function(link, doc) {
if (link == "about:blank") return true;
if (DoGoodFilter.RegExpWhiteList(link)) return true;
if (DoGoodCookie.readCookie('dogoodIgnore', doc) == 1) return true;
if (DoGoodCookie.readCookie('DoGoodShowAll', doc) == 'yes') return true;
return false;
},
/**
* Function for create cookie.
*
* @param {string} name - name of variable
* @param {string} value - value of variable
* @param {int} link - count days for saving
*/
createCookie : function(name, value, days) {
var doc = window.content.document;
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
doc.cookie = name+"="+value+expires+"; path=/";
},
/**
* Function for read cookie.
*
* @param {string} name - name of variable
* @param {object} doc - current loaded document
*/
readCookie : function(name, doc) {
if (!doc) doc = window.content.document;
var nameEQ = name + "=";
var ca = doc.cookie || null;
if (ca) {
ca = ca.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
}
return null;
}
};